<script src="__CDN__/assets/libs/jquery/dist/jquery.js"></script>
<script src="__CDN__/assets/addons/tongcheng/js/vue.js"></script>
<link rel="stylesheet" href="__CDN__/assets/addons/tongcheng/css/common.css">

<link rel="stylesheet" href="__CDN__/assets/addons/tongcheng/js/element-ui/index.css">
<script src="__CDN__/assets/addons/tongcheng/js/element-ui/index.js"></script>

<button class="hide" onclick="location.reload()" id="btnRefresh">刷新</button>
<div id="app">

  <el-card class="box-card" style="margin-bottom: 20px;">
    <!--<div slot="header" class="clearfix">
      <span>订单信息</span>
    </div>-->

    <el-tabs v-model="activeTab" @tab-click="handleTabClick">
      <el-tab-pane label="订单信息" name="order">
        {include file="../application/admin/view/tongcheng/delivery_order/detail-order.html" /}
      </el-tab-pane>
      <el-tab-pane label="费用说明" name="fee">
        {include file="../application/admin/view/tongcheng/delivery_order/detail-fee.html" /}
      </el-tab-pane>
      <el-tab-pane label="订单进程" name="process">
        {include file="../application/admin/view/tongcheng/delivery_order/detail-process.html" /}
      </el-tab-pane>
      <!--<el-tab-pane label="时间说明" name="time">
        {include file="../application/admin/view/tongcheng/delivery_order/detail-time.html" /}
      </el-tab-pane>-->
    </el-tabs>

    <!--订单信息-->


    <!--订单进程-->


    <!--费用说明-->


    <!--时间说明-->


  </el-card>

</div>

<script>
  var row = {:html_entity_decode(str_replace('&quot;', "'", json_encode($row)))};
  var ctrl = null;
  var app = new Vue({
    el: '#app',
    data: {
      row: row,
      activeTab: 'order',
      roles: {
        'CUSTOMER': {
          value: 'CUSTOMER',
          label: '客户',
          tag: 'success',
        },
        'ADMIN': {
          value: 'ADMIN',
          label: '管理员',
          tag: 'warning',
        },
        'SYSTEM': {
          value: 'SYSTEM',
          label: '系统',
          tag: 'info',
        },
        'RIDER': {
          value: 'RIDER',
          label: '司机',
          tag: 'primary',
        },
      },
    },
    computed: {

    },
    created() {

    },
    methods: {
      handleTabClick(tab, event) {
        console.log(tab, event);
        this.activeTab = tab.name
      },

      // 指派司机
      riderAssign(order_id) {
        ctrl.api.showRiderDialog(order_id, this.row.zone_id)
      },

        // 转单
        transfer(order_id) {
            ctrl.api.showRiderDialog(order_id, this.row.zone_id, 'transfer')
        },

      // 到达取货点
      riderArrive(order_id) {
        ctrl.api.riderArrive(order_id)
      },

      // 开始配送
      riderDelivering(order_id) {
        ctrl.api.riderDelivering(order_id)
      },

      // 完成配送
      complete(order_id) {
        ctrl.api.complete(order_id)
      },

      // 取消订单
      cancel(order_id) {
        ctrl.api.cancel(order_id)
      },

      // 同意退款
      refundAccept(order_id) {
        ctrl.api.refundAccept(order_id)
        /*this.$confirm('确定同意退款吗？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          ctrl.api.refundAccept(order_id)
          // this.$message({
          //   type: 'success',
          //   message: '删除成功!'
          // });
        }).catch(() => {

        });*/
      },

      // 拒绝退款
      refundReject(order_id) {
        ctrl.api.refundReject(order_id)
        /*this.$prompt('请输入拒绝理由', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }).then(({ value }) => {
          if (!value) {
            this.$message({
              type: 'warning',
              message: '请输入拒绝理由'
            });
            return
          }
          ctrl.api.refundReject(order_id, value)
        }).catch(() => {
        });*/
      },

      /**
       * 格式化秒数
       * @param second
       * @returns {string}
       */
      formatSecond: function (second) {
        if (second == 0) return '不限时'

        let result = parseInt(second)
        let h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600);
        let m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
        let s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));

        let res = '';
        if (h !== '00') res += `${h}时`;
        if (m !== '00') res += `${m}分`;
        res += `${s}秒`;
        return res;
      }
    }
  })
</script>
<style>

</style>